﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Web;
using DDMedlem;
namespace Data
{
    public class DB
    {
        
        public static string ConnectionString
        {
            get { return @"Data Source=(local);Initial Catalog=ddmedlemdb;Persist Security Info=True;User ID=ddsqlmedlem;Password=Oj561BV8Ga1Ax"; }
            
        }




        public static List<object[]> HentListe(string sqlQuery)
        {
            
            SqlConnection conn = new SqlConnection(ConnectionString);
            
            try
            {

                List<object[]> liste = new List<object[]>();

                conn.Open();
                SqlCommand com = new SqlCommand(sqlQuery, conn);
                SqlDataReader reader = com.ExecuteReader();

                while (reader.Read())
                {
                    object[] obj = new object[reader.FieldCount];
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        obj[i] = reader[i];
                    }

                    liste.Add(obj);
                }

                return liste;
            }


            catch(SqlException ex)
            {

                return new List<object[]>();
                throw new Exception(ex.Message);

            }

            finally
            {
                conn.Close();
            }
        }

        
    }
}
